import { Component } from "react";
class DemoEventFn extends Component{
    constructor () {
        super()
        this.state = {
            count:10
        }
    }
    add = () =>{
        console.log('this',this)
        this.setState({
            count:this.state.count + 1
        })
    }
    getId = (e) =>{
        console.log('e',e.target.dataset.id)
    }
    render(){
        return(<div className="serach">
            <h2>事件处理-更改this.指向</h2>
            count:{this.state.count}
            <button onClick={this.add.bind(this)}>使用bind count++</button>
            <button onClick={ this.add }>使用箭头函数的方式count++</button>
            <button data-id='100' onMouseLeave={(e)=> this.getId(e)}>点击跳转详情</button>
        </div>)
    }
}

export default DemoEventFn